package implementor;

import dao.StockOutDao;
import dbhandelling.Crude;
import dto.StockOut;


public class StockOutImplementor extends Crude implements StockOutDao
{
	String className=new StockOut().getClass().getName();
	@Override
	public void add(StockOut stockOuts) throws Exception 
	{
		insert(stockOuts);
	}

	@Override
	public void update(StockOut stockOuts) throws Exception 
	{
		super.update(className, "quantityOut",stockOuts.getQuantityOut()+"" , "autoStockCode",stockOuts.getautoStockCode()+"");
		super.update(className, "dates",stockOuts.getDates()+"" , "autoStockCode",stockOuts.getautoStockCode()+"");
		super.update(className, "issueSlipNo",stockOuts.getIssueSlipNo()+"" , "autoStockCode",stockOuts.getautoStockCode()+"");
		super.update(className, "specCode",stockOuts.getSpecCode()+"" , "autoStockCode",stockOuts.getautoStockCode()+"");
		
	}

	@Override
	public void delete(StockOut stockOuts) throws Exception 
	{
		delete(className, "autoStockCode",stockOuts.getautoStockCode()+"");
		
	}

	@Override
	public StockOut retreive(String conditionField, String ConditionValue) throws Exception 
	{
		StockOut stockOuts=(StockOut) super.retreive(className,conditionField, ConditionValue);
		return stockOuts;
	}

	@Override
	public StockOut[] retreiveArray(String conditionField, String conditionValue) throws Exception 
	{
		StockOut[] materialMasters;
		Object[] obj=super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		materialMasters=new StockOut[obj.length];
		
		for(int i=0;i<materialMasters.length;i++)
		{
			materialMasters[i]=(StockOut) obj[i];
		}
		
		return materialMasters;
	}

	@Override
	public StockOut[] retreiveAll() throws Exception 
	{
		StockOut[] materialMasters;
		
		Object[] obj=super.retreiveAll(className);
		
		materialMasters=new StockOut[obj.length];
		
		for(int i=0;i<materialMasters.length;i++)
		{
			materialMasters[i]=(StockOut) obj[i];
		}
		
		return materialMasters;
	}

}
